<?php

namespace app\admin\service;

use app\admin\dao\KeywordsAnalysisDao;
use app\admin\model\UM as UM;
use ShidianUtil\Utils\TimeUtil;

/**
 * Class KeywordsService
 * @package app\admin\service
 */
class KeywordsService
{

    private KeywordsAnalysisDao $keywordsAnalysisDao;

    public function __construct(KeywordsAnalysisDao $keywordsAnalysisDao)
    {
        $this->keywordsAnalysisDao = $keywordsAnalysisDao;
    }

    /**
     * 关键词统计列表
     * @param UM|null $user
     * @param $time
     * @param $kw
     * @param int|null $page
     * @param int|null $page_size
     * @return array
     */
    public function index(?UM $user, $time, $kw, ?int $page = null, ?int $page_size = null): array
    {
        $time = TimeUtil::stamp(TimeUtil::DAY, $time);

        return $this->keywordsAnalysisDao->listKeywords($time, $kw, $page, $page_size);
    }

}
